package com.gilgamesh.mall.oss.controller;

import com.gilgamesh.mall.oss.service.OssService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.net.URL;
import java.util.Map;

/**
 * @author yanm
 * @date 2021/1/14 22:00
 **/
@RestController
@RequestMapping("api/oss")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class OssController {

    private final OssService ossService;


    /**
    * 获取上传文件的url
     * @param dirName 文件名（由对应中心生成给出）
    *@return url
    *@author yanm
    *@date 2021/1/15 15:53
    **/
    @PostMapping("getUpLoadToken")
    public Map<String, String> getUpLoadToken(@RequestParam(value = "dirName") String dirName) {
        return ossService.getUpLoadToken( dirName);
    }
}
